package com.br.rh.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.br.rh.vo.Parentesco;

public class ParentescoDAO extends DataUtils {
	public List<Parentesco> getAll() {
		List<Parentesco> lista = new ArrayList<Parentesco>();
		try {
			Connection conn = getConnection();
			PreparedStatement stmt = conn.prepareStatement("SELECT * FROM parentesco");
			ResultSet rs = stmt.executeQuery();
			
			Parentesco parentesco = null;
			while(rs.next()){
				parentesco = new Parentesco();
				parentesco.setCodigo(rs.getInt(1));
				parentesco.setNomeMae(rs.getString(2));
				parentesco.setSobMae(rs.getString(3));
				parentesco.setNomePai(rs.getString(4));
				parentesco.setSobPai(rs.getString(5));
				lista.add(parentesco);				
			}
			conn.close();
			stmt.close();
			rs.close();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return lista;
	}
}
